package com.zhanggm.springcloud.jpa.service.impl;

import com.zhanggm.springcloud.jpa.repository.TbSkillRepository;
import com.zhanggm.springcloud.jpa.service.TbSkillService;
import com.zhanggm.springcloud.jpa.entity.TbSkill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
@author Zhanggm
*/
@Service
public class TbSkillServiceImpl implements TbSkillService {

	@Resource
	private TbSkillRepository skillRepository;

	@Autowired
	private TbDocSkillServiceImpl docSkillService;

	@Autowired
	private TbSkillService skillService;

	@Override
	public TbSkill getById(Integer id) {
		return skillRepository.findById(id).get();
	}

	@Override
	public List<TbSkill> getAll() {
		return skillRepository.findAll();
	}

	@Override
	public List<TbSkill> getListByDoctorId(Integer doctorId) {
        List<Integer> skillIdList = docSkillService.getSkillIdListByDockerId(doctorId);
        return skillRepository.findAllById(skillIdList);
	}
}
